package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from login where nickname=#{nickname}")
    User selectByName(String nickname);

    @Select("select * from login where id=#{id}")
    User selectById(String id);

    @Insert("<script> insert into login "
            + "(id,nickname,realname,part,password,role,status) "
            + "values "
            + "<foreach collection = 'list' item='record' separator=',' > "
            + " (#{record.id},#{record.nickname},#{record.realname},#{record.part},#{record.password},#{record.role},#{record.status}) "
            + "</foreach>"
            + "</script>")
    int MultiAdd(List<User> list);

    @Select("<script>select * from login where id in " +
            "<foreach collection = 'list' item='id' separator=','  open='(' close=')'>#{id}</foreach></script>")
    List<User> MultiSelect(List<String> list);
}
